package com.reservation.service.impl;

import com.reservation.entity.Venue;
import com.reservation.mapper.VenueMapper;
import com.reservation.service.VenueService;
import com.reservation.util.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class VenueServiceImpl implements VenueService {
    
    @Autowired
    private VenueMapper venueMapper;
    
    @Override
    public List<Venue> findAll() {
        return venueMapper.findAll();
    }
    
    @Override
    public List<Venue> findByPage(PageParam pageParam) {
        int total = venueMapper.count();
        pageParam.setTotal(total);
        return venueMapper.findByPage(pageParam.getOffset(), pageParam.getPageSize());
    }
    
    @Override
    public Venue findById(Integer id) {
        return venueMapper.findById(id);
    }
    
    @Override
    public int save(Venue venue) {
        venue.setStatus("available");
        return venueMapper.insert(venue);
    }
    
    @Override
    public int update(Venue venue) {
        return venueMapper.update(venue);
    }
    
    @Override
    public int deleteById(Integer id) {
        return venueMapper.deleteById(id);
    }
    
    @Override
    public int updateStatus(Integer id, String status) {
        return venueMapper.updateStatus(id, status);
    }
} 